﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LevelMasterForm.aspx.cs"
    Inherits="FX.CC.Andon.WebSite.BasicDataManage.LevelMasterForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>汇报层级定义</title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <div class="mini-splitter" style="width: 100%; height: 100%;">
        <div size="50%" showcollapsebutton="true">
            <div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
                <table style="width: 100%;">
                    <tr>
                        <td>
                            &nbsp;&nbsp;产线：<div id="LineID" name="LineID" class="mini-combobox" style="width: 120px;"
                                popupwidth="300" onvaluechanged="onLineIDChanged" textfield="LineName" valuefield="LineID"
                                url="../Service/BasicDataManageHandler.ashx?action=GetLineListByCombobox">
                                <div property="columns">
                                    <div header="产线编号" field="LineCode" width="40%">
                                    </div>
                                    <div header="产线名称" field="LineName" width="60%">
                                    </div>
                                </div>
                            </div>
                            &nbsp;&nbsp;异常原因：
                            <div id="ETypeCode" name="ETypeCode" class="mini-combobox" style="width: 120px;"
                                onvaluechanged="onETypeCodeChanged" popupwidth="300" textfield="ETypeName" valuefield="ETypeCode"
                                url="../Service/BasicDataManageHandler.ashx?action=GetETypeListByCombobox">
                                <div property="columns">
                                    <div header="异常原因编号" field="ETypeCode" width="40%">
                                    </div>
                                    <div header="异常原因名称" field="ETypeName" width="60%">
                                    </div>
                                </div>
                            </div>
                            &nbsp;&nbsp;超时通知类别：
                            <input id="TimeoutStatus" name="TimeoutStatus" shownullitem="true" style="width: 120px;"
                                class="mini-combobox" textfield="text" valuefield="id" data="TimeoutStatusdata"
                                onvaluechanged="onTimeoutStatusChanged" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
                <a class="mini-button" iconcls="icon-add" onclick="add();" plain="true">添加</a> <a
                    class="mini-button" iconcls="icon-edit" onclick="edit()" plain="true">编辑</a>
                <a class="mini-button" iconcls="icon-remove" onclick="remove()" plain="true">删除</a>
                <span class="separator"></span><a class="mini-button" onclick="close()" iconcls="icon-close"
                    plain="true">关闭</a>
            </div>
            <div class="mini-fit">
                <div id="grid1" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="LvID"
                    borderstyle="border:0;" sizelist="[10,20,50,100]" pagesize="20" onselectionchanged="onSelectionChanged"
                    selectonload="true" onrowdblclick="ondoubleclick()">
                    <div property="columns">
                        <div type="indexcolumn">
                        </div>
                        <div field="LineName" width="120" headeralign="center" allowsort="true">
                            产线名称
                        </div>
                        <div field="ETypeCode" width="90" headeralign="center" allowsort="true">
                            异常原因编号
                        </div>
                        <div field="ETypeName" width="110" headeralign="center" allowsort="true">
                            异常原因名称
                        </div>
                        <div field="LevelIdx" width="40" headeralign="center" allowsort="true">
                            层次
                        </div>
                        <div field="MsgTimeOut" width="120" headeralign="center" allowsort="true">
                            自动上发超时(分钟)
                        </div>
                        <div field="TimeoutStatus" width="120" headeralign="center" allowsort="true" renderer="onTimeoutStatusRenderer">
                            超时通知类别
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div showcollapsebutton="true">
            <div class="mini-fit">
                <div id="grid2" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="RowID"
                    borderstyle="border:0;" sizelist="[10,20,50,100]" pagesize="20">
                    <div property="columns">
                        <div type="indexcolumn">
                        </div>
                        <div field="LoginCode" width="120" headeralign="center" allowsort="true">
                            登录账号
                        </div>
                        <div field="FullName" width="120" headeralign="center" allowsort="true">
                            姓名
                        </div>
                        <div field="MobileNo" width="120" headeralign="center" allowsort="true">
                            手机号码
                        </div>
                        <div field="DptName" width="100" headeralign="center" allowsort="true">
                            所属部门
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript">
    var TimeoutStatusdata = [{ id: 0, text: '处理超时通知' }, { id: 1, text: '签到超时通知'}];
    mini.parse();
    var grid1 = mini.get("grid1");
    var grid2 = mini.get("grid2");
    function onLineIDChanged(e) {
        var ETypeCode = mini.get("ETypeCode").getValue();
        var TimeoutStatus = mini.get("TimeoutStatus").getValue();
        if (ETypeCode) {
            grid1.setUrl("../service/BasicDataManageHandler.ashx?action=GetLevelList");
            grid1.load({ ETypeCode: ETypeCode, LineID: e.value, TimeoutStatus: TimeoutStatus });
        }
    }
    function onETypeCodeChanged(e) {
        var LineID = mini.get("LineID").getValue();
        var TimeoutStatus = mini.get("TimeoutStatus").getValue();
        if (LineID) {
            grid1.setUrl("../service/BasicDataManageHandler.ashx?action=GetLevelList");
            grid1.load({ ETypeCode: e.value, LineID: LineID, TimeoutStatus: TimeoutStatus });
        }
    }
    function onTimeoutStatusChanged(e) {
        var ETypeCode = mini.get("ETypeCode").getValue();
        var LineID = mini.get("LineID").getValue();
        if (LineID) {
            grid1.setUrl("../service/BasicDataManageHandler.ashx?action=GetLevelList");
            grid1.load({ ETypeCode: ETypeCode, LineID: LineID, TimeoutStatus: e.value });
        }
    }
    function onSelectionChanged(e) {
        var gridLevel = e.sender;
        var record = gridLevel.getSelected();
        if (record) {
            grid2.setUrl("../Service/BasicDataManageHandler.ashx?action=GetLevelDetailList");
            grid2.load({ LvID: record.LvID });
        }
        else {
            grid2.clearRows();
        }
    }

    function add() {
        mini.open({
            url: "BasicDataManage/LevelInfoForm.aspx",
            title: "新增汇报层级", width: 800, height: 530,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { action: "new" };
                iframe.contentWindow.SetData(data);
            },
            ondestroy: function (action) {
                grid1.reload();
            }
        });
    }
    function ondoubleclick() {
        edit();
    }
    function edit() {
        var row = grid1.getSelected();
        if (row) {
            mini.open({
                url: "BasicDataManage/LevelInfoForm.aspx",
                title: "编辑汇报层级", width: 800, height: 530,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "edit", LvID: row.LvID };
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid1.reload();
                }
            });

        } else {
            mini.alert("请选中一条需要编辑的记录!");
        }
    }
    function remove() {
        var rows = grid1.getSelected();
        if (rows) {
            $.ajax({
                url: "../service/BasicDataManageHandler.ashx?action=GetMaxLevelIdxs&LineID=" + rows.LineID + "&ETypeCode=" + rows.ETypeCode + "&TimeoutStatus=" + rows.TimeoutStatus,
                success: function (text) {
                    if (rows.LevelIdx < text) {
                        mini.alert("当前为第" + rows.LevelIdx + "层,请先删除第" + text + "层!");
                    }
                    else if (rows.LevelIdx == text) {
                        mini.confirm("您确定删除第" + rows.LevelIdx + "层数据吗？", "确定？",
                        function (action) {
                            if (action == "ok") {
                                $.ajax({
                                    url: "../service/BasicDataManageHandler.ashx?action=RemoveLevel&LvID=" + rows.LvID,
                                    success: function (text) {
                                        grid1.reload();
                                    },
                                    error: function () {
                                    }
                                });

                            } else {
                                return false;
                            }
                        });
                    }
                },
                error: function () {
                }
            });
        } else {
            mini.alert("请选中一条您需要删除的记录!");
        }
    }
    function onTimeoutStatusRenderer(e) {
        if (e.value == "0") { return "<span >处理超时通知</span>"; }
        else if (e.value == "1") { return "<span >签到超时通知</span>"; }
        else { return ""; }
    }
    function CloseWindow(action) {
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }

    function close() {
        CloseWindow("close");
    }
</script>
</html>
